<%@ Page Language="C#" MasterPageFile="~/master/admin.master" AutoEventWireup="true"
    CodeFile="newsletter-archive.aspx.cs" Inherits="admin_newsletter_archive" Title="Untitled Page" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register Namespace="ECommerce.Library.Web" TagPrefix="ucc" %>
<%@ Register Src="~/controls/wucAdminValidator.ascx" TagName="AdminValidator" TagPrefix="wuc" %>
<asp:Content ID="cntMiddleContent" ContentPlaceHolderID="cphMiddleContent" runat="Server">
    <script type="text/javascript">

        var Date_Renderer = function (value) {
            var dt = new Date(value);
            return dt.format('m/d/Y');
        }

        var ViewLink_Renderer = function (value, p, record, rowIndex) {
            var categoryUrl = String.format("<%= Page.ResolveUrl(eShop.Business.CustomSiteMap.NewsletterPrint) %>?id={0}", record.data.NewsletterId);
            return String.format("<a href=\"{0}\" class=\"leftlink\" target=\"_blank\">{1}</a>", categoryUrl, "View");
        };

        var categoryGrid;


        var onDocumentReady = function (grid) {
            categoryGrid = grid;
        }

    </script>
    <ext:ResourceManager ID="ScriptManager1" runat="server" Theme="Gray">
        <Listeners>
            <DocumentReady Fn="onDocumentReady(#{GridPanel1})" />
        </Listeners>
    </ext:ResourceManager>
    <ext:Store ID="Store1" runat="server" RemoteSort="true" OnRefreshData="Store1_RefreshData">
        <AutoLoadParams>
            <ext:Parameter Name="sort" Value="Date" Mode="Value" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="limit" Value="20" Mode="Raw" />
        </AutoLoadParams>
        <Proxy>
            <ext:PageProxy />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="NewsletterId">
                <Fields>
                    <ext:RecordField Name="NewsletterId" />
                    <ext:RecordField Name="Subject" />
                    <ext:RecordField Name="Date" Type="Date" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <div class="admin-function-top inline">
        <ext:GridPanel ID="GridPanel1" runat="server" EnableViewState="true" AutoHeight="true"
            StoreID="Store1">
            <ColumnModel>
                <Columns>
                    <ext:Column Header="Subject" Width="100" DataIndex="Subject">
                    </ext:Column>
                    <ext:Column Header="Date" Width="50" DataIndex="Date">
                        <Renderer Fn="Date_Renderer" />
                    </ext:Column>
                    <ext:Column Header="" Width="50" DataIndex="NewsletterId" Sortable="false">
                        <Renderer Fn="ViewLink_Renderer" />
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <SelectionModel>
                <ext:RowSelectionModel runat="server" />
            </SelectionModel>
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="20" DisplayInfo="true"
                    DisplayMsg="Displaying newsletters {0} - {1} of {2}" EmptyMsg="No newsletters to display"
                    AutoWidth="true" />
            </BottomBar>
            <LoadMask ShowMask="true" />
            <View>
                <ext:GridView ID="GridView1" runat="server" ForceFit="true" />
            </View>
        </ext:GridPanel>
    </div>
</asp:Content>
